Shader "CZS/vertexColorTest"
{
    Properties
    {
        _OutlineWidth("OutlineWidth",Float) = 0.1

    }

    SubShader
    {
        // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
        // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
        // material work with both Universal Render Pipeline and Builtin Unity Pipeline
        Tags
        {
            "RenderType" = "Opaque"
            "RenderPipeline" = "UniversalPipeline"
            "UniversalMaterialType" = "Lit"
            //            "IgnoreProjector" = "True"
        }
        LOD 300

        Pass
        {
            Tags
            {
                "LightMode" = "SRPDefaultUnlit"
            }
            Cull Front

            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            #pragma shader_feature _USE_OUTLINE

            float4 _OutlineColor;
            float _OutlineWidth;

            struct Attributes
            {
                float4 positionOS : POSITION;
                float3 normalOS : NORMAL;
                float4 tangentOS : TANGENT;
                float2 uv : TEXCOORD0;
                float4 color : COLOR;
            };

            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float2 uv : TEXCOORD0;
                float4 color : COLOR;
                float4 vertexColor : TEXCOORD1;
            };

            Varyings vert(Attributes input)
            {
                Varyings output = (Varyings)0;
                float3 offset = input.normalOS * _OutlineWidth * input.color.r;
                float4 posOSOffset = float4(input.positionOS.xyz + offset, input.positionOS.w);
                output.positionCS = TransformObjectToHClip(posOSOffset);
                output.uv = input.uv;
                output.vertexColor = input.color;
                return output;
            }

            half4 frag(Varyings i) : SV_TARGET
            {
                return i.vertexColor;
            }
            ENDHLSL
        }


    }

    FallBack "Hidden/Universal Render Pipeline/FallbackError"
    //    CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
}